home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / opussdk / include / dopus / lists.h < prev    next >
C/C++ Source or Header  |  1996-08-30  |  2KB  |  77 lines

  1. #ifndef _DOPUS_LISTS
  2. #define _DOPUS_LISTS
  3.  
  4. /*****************************************************************************
  5.  
  6.  List management
  7.  
  8.  *****************************************************************************/
  9.  
  10. typedef struct _Att_List
  11. {
  12.     struct List        list;        // List structure
  13.     struct SignalSemaphore    lock;        // Semaphore for locking
  14.     ULONG            flags;        // Flags
  15.     APTR            memory;        // Memory pool
  16.     struct _Att_Node    *current;    // Current node (application use)
  17. } Att_List;
  18.  
  19. #define LISTF_LOCK        (1<<0)        // List requires locking
  20. #define LISTF_POOL        (1<<1)        // Use memory pooling
  21.  
  22. typedef struct _Att_Node
  23. {
  24.     struct Node        node;        // Node structure
  25.     Att_List        *list;        // Pointer back to list
  26.     ULONG            data;        // User data
  27. } Att_Node;
  28.  
  29. #define ADDNODEF_SORT        1        // Sort names
  30. #define ADDNODEF_EXCLUSIVE    2        // Exclusive entry
  31. #define ADDNODEF_NUMSORT    4        // Numerical name sort
  32. #define ADDNODEF_PRI        8        // Priority insertion
  33.  
  34. #define REMLISTF_FREEDATA    1        // FreeVec data when freeing list
  35. #define REMLISTF_SAVELIST    2        // Don't free list itself
  36.  
  37. void AddSorted(struct List *,struct Node node);
  38. void Att_ChangeNodeName(Att_Node *,char *);
  39. Att_Node *Att_FindNode(Att_List *,long);
  40. Att_Node *Att_FindNodeData(Att_List *,ULONG);
  41. long Att_FindNodeNumber(Att_List *,Att_Node *);
  42. Att_List *Att_NewList(ULONG);
  43. Att_Node *Att_NewNode(Att_List *,char *,ULONG,ULONG);
  44. long Att_NodeCount(Att_List *);
  45. long Att_NodeDataNumber(Att_List *,ULONG);
  46. char *Att_NodeName(Att_List *,long);
  47. long Att_NodeNumber(Att_List *,char *);
  48. void Att_PosNode(Att_List *,Att_Node *,Att_Node *);
  49. void Att_RemList(Att_List *,long);
  50. void Att_RemNode(Att_Node *);
  51. struct Node *FindNameI(struct List *,char *);
  52. void LockAttList(Att_List *,BOOL);
  53. void SwapListNodes(struct List *,struct Node *,struct Node *);
  54. void UnlockAttList(Att_List *);
  55.  
  56.  
  57. /*****************************************************************************
  58.  
  59.  Semaphore management
  60.  
  61.  *****************************************************************************/
  62.  
  63. struct ListLock {
  64.     struct List        list;
  65.     struct SignalSemaphore    lock;
  66. };
  67.  
  68. #define SEMF_SHARED        0
  69. #define SEMF_EXCLUSIVE        (1<<0)
  70. #define SEMF_ATTEMPT        (1<<1)
  71.  
  72. long GetSemaphore(struct SignalSemaphore *,long,APTR);
  73. void InitListLock(struct ListLock *,APTR);
  74. BOOL IsListLockEmpty(struct ListLock *);
  75.  
  76. #endif
  77.